import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class SeckillOrderDetailInfoItem extends StatelessWidget {

  final String title;
  final String value;
  final bool showCopy;
  SeckillOrderDetailInfoItem({
    required this.title,
    required this.value,
    this.showCopy = false
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 12.h),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(
            title,
            style: TextStyle(
              color: textSubtitleColor,
              fontSize: 14.sp,
              // height: 1.1
            ),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              InkWellUtil.shakeProofInkWell(Text(
                value,
                style: TextStyle(
                  color: textBlackColor,
                  fontSize: 14.sp,
                  height: 1.1
                ),
              ), () {
                if (showCopy) {
                  Clipboard.setData(ClipboardData(text: value));
                  EasyLoading.showToast('复制成功');
                }
              }),
              showCopy ? Container(
                margin: EdgeInsets.only(left: 10.w),
                child: InkWellUtil.shakeProofInkWell(Text(
                  '复制',
                  style: TextStyle(
                    color: mainTextColor,
                    fontSize: 12.sp,
                    height: 1.1
                  ),
                ), () {
                  Clipboard.setData(ClipboardData(text: value));
                  EasyLoading.showToast('复制成功');
                }),
              ) : Container()
            ],
          )
        ],
      ),
    );
  }
}